package com.example.demo.mapper;

import com.example.demo.entity.CourseCategory;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CourseCategoryMapper {
    // 新增课程分类
    @Insert("INSERT INTO course_categories (name, description) VALUES (#{name}, #{description})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertCourseCategory(CourseCategory courseCategory);

    // 删除课程分类
    @Delete("DELETE FROM course_categories WHERE id = #{id}")
    int deleteCourseCategoryById(int id);

    // 修改课程分类
    @Update("UPDATE course_categories SET name = #{name}, description = #{description} WHERE id = #{id}")
    int updateCourseCategory(CourseCategory courseCategory);

    // 查询课程分类
    @Select("SELECT * FROM course_categories WHERE id = #{id}")
    CourseCategory selectCourseCategoryById(int id);

    // 查询所有课程分类
    @Select("SELECT * FROM course_categories")
    List<CourseCategory> selectAllCourseCategories();
}